(function(){
	var elementId = null;//要显示时间的html元素的id
	
	var getNowTime = function(){
		var now = new Date();
		var h = now.getHours();
		var m = now.getMinutes();
		var s = now.getSeconds(); 
		h = h < 10 ? '0'+h : h;
		m = m < 10 ? '0'+m : m;
		s = s < 10 ? '0'+s : s;
		return h + ":" + m + ":" + s;
	}
	
	setNowTime = function(){
		for (i = 0; i < elementId.length; i++) {
			document.getElementById(elementId[i].trim()).innerHTML = getNowTime();
		}
	}
	
	var startTime = function(id){
		elementId = id.split(',');
		window.setInterval('setNowTime()',1000);
	}
	
	return startTime;
}())('time');//表示时间控件的id为time；如果有多个控件都要显示时间，多个id用逗号隔开。
